//
//  RYVideoCell.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/14.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit


class RYVideoCell: SYBaseCell , UICollectionViewDelegate, UICollectionViewDataSource{
    
    var collectionView: UICollectionView!

    public func configureView() {
        
    }
    
    override func initViews() {
        
        setCollectionView()

        contentView.addSubview(collectionView)
        
        collectionView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(autoWidth(15.0))
            make.right.equalToSuperview().offset(autoWidth(-15.0))
            make.left.equalToSuperview().offset(autoWidth(15.0))
            make.height.equalTo(SCREEN_HEIGHT*1000)
            make.bottom.equalToSuperview().offset(autoWidth(-15.0))
        }
     
    }
    
    func setCollectionView() {
        
            
        let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
        let itemWidth = 109.0.autoWidth()
        layout.itemSize = CGSize(width: itemWidth, height: 88.autoWidth())
        layout.minimumLineSpacing = 10
        layout.minimumInteritemSpacing = 1
        layout.scrollDirection = .vertical
        collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)
        collectionView.backgroundColor = .white
        collectionView.showsHorizontalScrollIndicator = false
        
        
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.register(RYVideoSubCell.self, forCellWithReuseIdentifier: NSStringFromClass(RYVideoSubCell.self))
        self.addSubview(self.collectionView)
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 55
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell: RYVideoSubCell? = collectionView.dequeueReusableCell(withReuseIdentifier: NSStringFromClass(RYVideoSubCell.self), for: indexPath) as? RYVideoSubCell
        if indexPath.row == 1 {
            cell?.backgroundColor = .blue
        }
        return cell!
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        
    }
    
   
}



class RYVideoSubCell: SYBaseCollectionViewCell {
    
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        
//        v.image = UIImage(named: "wen")
        v.layer.cornerRadius = 6
        return v
    }()
    
    let play: UIImageView = {
        let v: UIImageView = UIImageView()
        v.image = UIImage(named: "bofang")
        return v
    }()
    
    let priceLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        v.text = "00:00-04:00"
        return v
    }()
    

    public func configureView() {
        
    }
    
    override func initViews() {
        
        
        addSubview(pic)
        pic.addSubview(play)
        addSubview(priceLb)
        pic.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.right.equalToSuperview()
            make.width.equalTo(109.autoWidth())
            make.height.equalTo(61.autoWidth())
        }
        play.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.height.width.equalTo(16.autoWidth())
        }
        priceLb.snp.makeConstraints { (make) in
            make.top.equalTo(pic.snp.bottom).offset(9.autoWidth())
            make.centerX.equalTo(pic)
            make.height.equalTo(10.0.autoWidth())
        }
    }
}

